package com.pro.controller;

import com.pro.pojo.JsUserOrder;
import com.pro.pojo.JsonData;
import com.pro.service.JsUserOrderShippedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * ClassName:JsUserOrderShippedController
 * Package:com.pro.controller
 * Description: 商品已发货列表
 *
 * @Date:2021/11/10 上午 9:06
 * @Author: WYH
 */
@Controller
@RequestMapping("/orderShipped")
public class JsUserOrderShippedController {

    @Autowired
    private JsUserOrderShippedService jsUserOrderShippedService;

    /**
     * @author WYH
     * @date 2021/11/10 上午 10:58
     * @content : 查询所有商品已发货货列表表格数据
     */
    @RequestMapping("/getAllorder")
    @ResponseBody
    public JsonData getAllorder(String orderPaymentChannel, String orderSource) {
        orderPaymentChannel = orderPaymentChannel != null ? "%"+orderPaymentChannel+"%" : "%%";
        orderSource = orderSource != null ? "%"+orderSource+"%" : "%%";
        List<JsUserOrder> allorder = jsUserOrderShippedService.getAllorder(orderPaymentChannel,orderSource);
        int count = jsUserOrderShippedService.count(orderPaymentChannel, orderSource);
        return allorder != null ? JsonData.buildSuccess(allorder,count) : JsonData.buildError("数据格式异常");
    }

    /**
     * @author WYH
     * @date 2021/11/10 上午 10:58
     * @content : 删除商品已发货列表表格数据
     */
    public int count(String orderPaymentChannel, String orderSource) {
        int count = jsUserOrderShippedService.count(orderPaymentChannel, orderSource);
        return count;
    }

}
